#include<cstdio>

int main()
{
	int i,D,I,t=1;
	scanf("%d%d",&D,&I);
	for (i=1;i<D;i++)
	{
		if (I%2)
		{
			t=t*2;
			I=(I+1)/2;
		}
		else
		{
			t=t*2+1;
			I=I/2;
		}
	}
	printf("%d\n",t);
	return 0;
}
